<?php
function lastday()
{
  global $mysqlhost, $mysqluser, $mysqlpw, $mysqlname;
  $db = new mysqli($mysqlhost, $mysqluser, $mysqlpw, $mysqlname);
  //Letzten Eintrag herausfinden 
  $lastentry = 'SELECT datentime FROM bz_werte_'.$_SESSION['id'].' ORDER BY datentime DESC';
  $entries = $db->query($lastentry);
  $row = $entries->fetch_assoc();
  return substr($row['datentime'],0,8);
}

function firstday()
{
  global $mysqlhost, $mysqluser, $mysqlpw, $mysqlname;
  $db = new mysqli($mysqlhost, $mysqluser, $mysqlpw, $mysqlname);
  //Letzten Eintrag herausfinden 
  $lastentry = 'SELECT datentime FROM bz_werte_'.$_SESSION['id'].' ORDER BY datentime ASC';
  $entries = $db->query($lastentry);
  $row = $entries->fetch_assoc();
  return substr($row['datentime'],0,8);
}

function jumptodate($date = "")
{
global $l_monate;
echo "<form action=\"".$_SERVER['PHP_SELF']."\" method=\"POST\"> <select name=\"day\" size=\"1\">";
for($i=1;$i<32;$i++)
{
  echo "<option";
  if ($i == substr($date,-2))
  {
    echo " selected";
  }
  echo ">";
  if($i < "10")
  {
    echo "0".$i;
  }
  else
  {
    echo $i;
  }
  echo "</option>";
}
echo "</select>
<select name=\"month\" size=\"1\">";
for($i=1;$i<13;$i++)
{
  echo "<option value=\"";
  if($i < "10")
  {
    echo "0".$i;
  }
  else
  {
    echo $i;
  }
  echo "\"";
  if ($i == substr($date,-4,2))
  {
    echo " selected";
  }
  echo ">".$l_monate[$i]."</option>";
}
echo "</select>
<select name=\"year\" size=\"1\">";
for($i = 2008;$i <= 2010; $i++)
{
  echo "<option";
  if ($i == substr($date,0,4))
  {
    echo " selected";
  }
  echo ">".$i."</option>";
}
echo "</select> <input type=\"submit\" value=\"Anzeigen\"></form>";
}
?>
